package cn.mapper;

import cn.entity.QualificationCondition;
import org.springframework.util.StringUtils;

public class QualificationProvider {

    public String selectPage(QualificationCondition condition) {
        StringBuilder sb = new StringBuilder();
        sb.append("select qu.*,su.name apply_name,ys.name check_name from qualification qu left join sys_user su on qu.upload_user_id = su.id " +
                "left join sys_user ys on qu.check_user_id = ys.id " +
                "WHERE qu.del_flag = '0'");
        if (!StringUtils.isEmpty(condition.getCreateDate())) {
            sb.append("and qu.create_date >= #{createDate}");
        }
        if (!StringUtils.isEmpty(condition.getEndDate())) {
            sb.append("and qu.create_date <= #{endDate}");
        }
        if (!StringUtils.isEmpty(condition.getCheck())) {
            sb.append("and qu.check = #{check}");
        }
        if (!StringUtils.isEmpty(condition.getType())) {
            sb.append("and qu.type = #{type}");
        }
        return sb.toString();
    }

    public String selectUpdate(Long id){
        StringBuilder sb = new StringBuilder();
        sb.append("select qu.*,su.company_id cid FROM qualification qu left join sys_user su on qu.upload_user_id =su.id where qu.id=");
        sb.append(id);
        return sb.toString();
    }
}
